﻿#pragma once


#include <QDialog>
#include <QMap>
#include <QString>

// Forward declarations
class QListWidget;
class QLineEdit;
class QPushButton;
class QLabel;

class UserManager : public QDialog
{
    Q_OBJECT

public:
    explicit UserManager(QWidget *parent = nullptr);
    ~UserManager();
    QString m_path = "user_data.dat";
    bool authenticateUser(const QString &username, const QString &password) const;
    void loadFromFile();
    // Data storage
    QMap<QString, QString> m_userDatabase; // <username, password>
private slots:
    void addUser();
    void removeUser();
    //void editUser();
    //void saveChanges();


private:
    void initializeUI();
    void setupConnections();

    void saveToFile();
    void refreshUserList();

    // UI components
    QListWidget *m_userListWidget;
    QLineEdit *m_usernameInput;
    QLineEdit *m_passwordInput;
    QPushButton *m_addButton;
    QPushButton *m_removeButton;
   /* QPushButton *m_editButton;
    QPushButton *m_saveButton;*/


    QString m_currentEditUser;             // Currently edited username

    // Constants
    static const QString DATA_FILENAME;
};


